<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 将globalCompositeOperation 这个属性写在目标图像后面 -->
    <canvas id="canvas" width="800" height="800"></canvas>
    <script>
        var canvas = document.getElementById('canvas')
        var ctx = canvas.getContext('2d')
        ctx.fillStyle = 'pink'
        ctx.fillRect(100,100,200,200)

        // ctx.globalCompositeOperation = 'source-over'
        // ctx.globalCompositeOperation = 'source-atop'
        // ctx.globalCompositeOperation = 'source-in'
        // ctx.globalCompositeOperation = 'source-out'
        // ctx.globalCompositeOperation = 'destination-over'
        // ctx.globalCompositeOperation = 'destination-atop'
        // ctx.globalCompositeOperation = 'destination-in'
        // ctx.globalCompositeOperation = 'destination-out'
        // ctx.globalCompositeOperation = 'linear'
        // ctx.globalCompositeOperation = 'copy'
        ctx.globalCompositeOperation = 'xor'




        ctx.fillStyle = 'lightBlue'
        ctx.fillRect(200,200, 200,200)

        
    </script>
</body>
</html>